import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { ItemData } from "../../../resource/info/ItemData";
import { MagicWeaponItemData } from "../MagicWeaponItemData";
import { ObjCreate } from "../../common/ObjCreate";
import { DisplayUtil } from "../../../../common/DisplayUtil";
import { EffectManager } from "../../../manager/EffectManager";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../../extend/language/Language";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { BaseItem } from "../../common/BaseItem";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
//class ResolveItemRenderer
    
    export  class ResolveItemRenderer extends NoSkinCellRenderer
    {
        constructor(arg1: Boolean=true)
        {
            super();
            setSize(76, 76);
            this.init();
            this._needBg = arg1;
            return;
        }

        public get itemData(): ItemData
        {
            if (this._baseItem && this._baseItem.itemData) 
            {
                return this._baseItem.itemData;
            }
            return null;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            var loc1=arg1 as MagicWeaponItemData;
            if (loc1) 
            {
                this._baseItem.itemData = loc1.itemData;
                if (loc1.itemData) 
                {
                    if (this._needBg) 
                    {
                        if (this._bg == null) 
                        {
                            this._bg = ObjCreate.createBg(5, 5, 56, 77);
                        }
                        this.removeHasIdentifyBg();
                        this.addChildAt(this._bg, 0);
                    }
                    else 
                    {
                        DisplayUtil.removeMe(this._gradeLabel);
                    }
                    if (loc1.itemData.magicWeaponScore >= 100 && this._needBg) 
                    {
                        EffectManager.glowFilterReg(this._bg, [FilterConst.colorGlowFilter(15788607)], 0.6, 10, 5, int.MAX_VALUE);
                    }
                    else 
                    {
                        EffectManager.glowFilterUnReg(this._bg);
                    }
                    this._gradeLabel.htmlText = HTMLUtil.addColor(Language.getStringByParam(27673, loc1.itemData.magicWeaponScore), "#ffff00");
                }
                else 
                {
                    this.removeHasIdentifyBg();
                    EffectManager.glowFilterUnReg(this._bg);
                    this._gradeLabel.htmlText = "";
                }
            }
            return;
        }

        /* internal  */removeHasIdentifyBg(): void
        {
            if (this._bg && this.contains(this._bg)) 
            {
                this.removeChild(this._bg);
            }
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ObjCreate.createBitmap(ImagesConst.AchievementIconBg, 10, 30, this);
            this._gradeLabel = ObjCreate.createGTextField("", 5, 8, 56, 25, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormatWhite));
            this._baseItem = new BaseItem();
            this._baseItem.isShowLock = true;
            this._baseItem.doubleClickEnabled = true;
            ObjCreate.setObjAttri(this._baseItem, 17, 37, 32, 32, this);
            return;
        }

        /* internal */ /* var */_gradeLabel: GTextFiled;

        /* internal */ /* var */_baseItem: BaseItem;

        /* internal */ /* var */_bg: ScaleBitmap;

        /* internal */ /* var */_needBg: Boolean;
    }
